/*
 * All rights Reserved, Copyright (C) wifi LIMITED 2019
 * FileName: OauthClientDetailsBean.java
 * Version:  $Revision$
 * Modify record:
 * NO. |     Date       |    Name         |      Content
 * 1   | 2019年12月3日        | wangjian    | original version
 */
package com.pl.service.impl;  

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pl.bean.OauthClientDetailsBean;
import com.pl.dao.OauthClientDetailsBeanDao;
import com.pl.service.OauthClientDetailsService;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.annotation.Resource;

/**
 * class name:OauthClientDetailsServiceImpl <BR>
 * class description:  <BR>
 * Remark: <BR>
 * @version 1.00 2019年12月3日
 * @author wangjian
 */
@Service("oauthClientDetailsService")
public class OauthClientDetailsServiceImpl extends ServiceImpl<OauthClientDetailsBeanDao, OauthClientDetailsBean> implements OauthClientDetailsService{

	private static Logger log = LogManager.getLogger();

	@Resource(name="oauthClientDetailsBeanDao")
	private OauthClientDetailsBeanDao oauthClientDetailsBeanDao;

	/**
	 * Method name: addOauthClientDetails <BR>
	 * Description: 新增 <BR>
	 * Remark: <BR>
	 * @param oauthClientDetailsBean  void<BR>
	 * @date 2019年12月3日
	 * @author wangjian
	 */
	@Transactional
	public void addOauthClientDetails(OauthClientDetailsBean oauthClientDetailsBean){
		
		oauthClientDetailsBeanDao.addOauthClientDetailsBean(oauthClientDetailsBean);
	}

	/**
	 * Method name: updateOauthClientDetails <BR>
	 * Description: 修改 <BR>
	 * Remark: <BR>
	 * @param oauthClientDetailsBean  void<BR>
	 * @date 2019年12月3日
	 * @author wangjian
	 */
	@Transactional
	public void updateOauthClientDetails(OauthClientDetailsBean oauthClientDetailsBean){
		
		oauthClientDetailsBeanDao.updateOauthClientDetailsBean(oauthClientDetailsBean);
	}
	
	/**
	 * Method name: getOauthClientDetailsNum <BR>
	 * Description: 根据条件获得数量 <BR>
	 * Remark: <BR>
	 * @param oauthClientDetailsBean
	 * @return  int<BR>
	 * @date 2019年12月3日
	 * @author wangjian
	 */
	public int getOauthClientDetailsNum(OauthClientDetailsBean oauthClientDetailsBean){
		
		return oauthClientDetailsBeanDao.getOauthClientDetailsBeanNum(oauthClientDetailsBean);
	}
	
	/**
	 * Method name: getOauthClientDetails <BR>
	 * Description: 根据条件获得数据 <BR>
	 * Remark: <BR>
	 * @param oauthClientDetailsBean
	 * @return  List<OauthClientDetailsBean><BR>
	 * @date 2019年12月3日
	 * @author wangjian
	 */
	public List<OauthClientDetailsBean> getOauthClientDetails(OauthClientDetailsBean oauthClientDetailsBean){
		
		return oauthClientDetailsBeanDao.getOauthClientDetailsBean(oauthClientDetailsBean);
	}
	
	/**
	 * Method name: getOauthClientDetailsByClientId <BR>
	 * Description: 根据条件获得数据 <BR>
	 * Remark: <BR>
	 * @param clientId
	 * @return  OauthClientDetailsBean<BR>
	 * @date 2019年12月3日
	 * @author wangjian
	 */
	public OauthClientDetailsBean getOauthClientDetailsByClientId(String clientId){
		
		OauthClientDetailsBean oauthClientDetailsBean = new OauthClientDetailsBean();
		oauthClientDetailsBean.setClientId(clientId);
		
		List<OauthClientDetailsBean> list = getOauthClientDetails(oauthClientDetailsBean);
		if(list !=null && !list.isEmpty()){
    		return list.get(0);
    	}
    	
    	return null;
	}

	@Override
	public void deleteByClientId(String clientId) {
		oauthClientDetailsBeanDao.deleteByClientId(clientId);
	}
}
